package com.muyu.danmo.controller;


import com.muyu.common.core.domain.Result;
import com.muyu.common.core.utils.poi.ExcelUtil;
import com.muyu.common.core.web.controller.BaseController;
import com.muyu.common.core.web.page.TableDataInfo;
import com.muyu.common.log.annotation.Log;
import com.muyu.common.log.enums.BusinessType;
import com.muyu.common.security.annotation.RequiresPermissions;
import com.muyu.danmo.domain.DanmoTrainingTeacher;
import com.muyu.danmo.service.IDanmoTrainingTeacherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 培训班教师Controller
 * 
 * @author yangle
 * @date 2024-11-26
 */
@RestController
@RequestMapping("/danmoTrainingTeacher")
public class DanmoTrainingTeacherController extends BaseController
{
    @Autowired
    private IDanmoTrainingTeacherService danmoTrainingTeacherService;

    /**
     * 查询培训班教师列表
     */
//    @RequiresPermissions("system:danmoTrainingTeacher:list")
    @GetMapping("/list")
    public Result<TableDataInfo<DanmoTrainingTeacher>> list(DanmoTrainingTeacher danmoTrainingTeacher)
    {
        startPage();
        List<DanmoTrainingTeacher> list = danmoTrainingTeacherService.selectDanmoTrainingTeacherList(danmoTrainingTeacher);
        return getDataTable(list);
    }

    /**
     * 导出培训班教师列表
     */
//    @RequiresPermissions("system:danmoTrainingTeacher:export")
    @Log(title = "培训班教师", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DanmoTrainingTeacher danmoTrainingTeacher)
    {
        List<DanmoTrainingTeacher> list = danmoTrainingTeacherService.selectDanmoTrainingTeacherList(danmoTrainingTeacher);
        ExcelUtil<DanmoTrainingTeacher> util = new ExcelUtil<DanmoTrainingTeacher>(DanmoTrainingTeacher.class);
        util.exportExcel(response, list, "培训班教师数据");
    }

    /**
     * 获取培训班教师详细信息
     */
//    @RequiresPermissions("system:danmoTrainingTeacher:query")
    @GetMapping(value = "/{id}")
    public Result getInfo(@PathVariable("id") Long id)
    {
        return success(danmoTrainingTeacherService.selectDanmoTrainingTeacherById(id));
    }

    /**
     * 新增培训班教师
     */
//    @RequiresPermissions("system:danmoTrainingTeacher:add")
    @Log(title = "培训班教师", businessType = BusinessType.INSERT)
    @PostMapping
    public Result add(@RequestBody DanmoTrainingTeacher danmoTrainingTeacher)
    {
        return toAjax(danmoTrainingTeacherService.insertDanmoTrainingTeacher(danmoTrainingTeacher));
    }

    /**
     * 修改培训班教师
     */
//    @RequiresPermissions("system:danmoTrainingTeacher:edit")
    @Log(title = "培训班教师", businessType = BusinessType.UPDATE)
    @PutMapping
    public Result edit(@RequestBody DanmoTrainingTeacher danmoTrainingTeacher)
    {
        return toAjax(danmoTrainingTeacherService.updateDanmoTrainingTeacher(danmoTrainingTeacher));
    }

    /**
     * 删除培训班教师
     */
    @RequiresPermissions("system:danmoTrainingTeacher:remove")
    @Log(title = "培训班教师", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public Result remove(@PathVariable Long[] ids)
    {
        return toAjax(danmoTrainingTeacherService.deleteDanmoTrainingTeacherByIds(ids));
    }
}
